﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CS544_Protocol_Client
{
    public partial class PrivateMessageForm : Form
    {

        private ClientControl myClientControl;
        public string toUsername { get; private set; } // hold name of the user the private message window is open to
       
        public PrivateMessageForm(ClientControl clientControl, string username)
        {
            InitializeComponent();
            myClientControl = clientControl;
            this.toUsername = username;
            this.Text = Text + " " + toUsername;
            this.messageTextBox.Focus();
        }
        
        //Add updated message to display
        public void addNewMessage(string sender, string message)
        {
            this.ChatTextBox.AppendText(sender + ": " + message + Environment.NewLine);
        }

        //Handle click even for send button
        private void SendButton_Click(object sender, EventArgs e)
        {
            addNewMessage(myClientControl.currentUser.Username, this.messageTextBox.Text);
            myClientControl.sendPrivateMessage(this.messageTextBox.Text, this.toUsername);
            messageTextBox.Clear();

        }

     





    }
}
